//登录关键数据
function getLoginData() {
  try {
    let { userInfo } = JSON.parse(localStorage.getItem("LOGIN_DATA"));
    let access_token = localStorage.getItem("ACCESS_TOKEN");
    let { Tenantcode, Syssource, client, statusBarHeight } = JSON.parse(
      localStorage.getItem("SYSTEM")
    );
    return {
      userId: userInfo.uid,
      token: access_token,
      sysSource: Syssource,
      tenantCode: Tenantcode,
      statusBarHeight,
      client,
    };
  } catch (error) {
    return {};
  }
}

function debounce(func, delay = 500) {
  var timer = null;
  return function () {
    var context = this;
    var args = arguments;
    if (timer) {
      clearTimeout(timer);
    }
    timer = setTimeout(function () {
      func.apply(context, args);
      timer = null;
    }, delay);
  };
}

//根据附件类型-筛选附件
function getFileTypeData(fileType) {
  fileType = fileType.toLowerCase();
  switch (fileType) {
    case ".pdf":
      return false;
    case ".doc":
    case ".docx":
      return false;
    case ".xls":
    case ".xlsx":
      return false;
    case ".ppt":
    case ".pptx":
    case ".pps":
      return false;
    case ".png":
    case ".jpg":
    case ".jpeg":
    case ".bmp":
    case ".gif":
      return true;
    default:
      return false;
  }
}
// 附件-文件类型图标
function getFileType(fileType) {
  fileType = fileType.toLowerCase();
  switch (fileType) {
    case ".pdf":
      return "https://jszhgd.cn/static/app/pdf.png";
    case ".doc":
    case ".docx":
      return "https://jszhgd.cn/static/app/doc.png";
    case ".xls":
    case ".xlsx":
      return "https://jszhgd.cn/static/app/xls.png";
    case ".ppt":
    case ".pptx":
    case ".pps":
      return "https://jszhgd.cn/static/app/ppt.png";
    case ".png":
    case ".jpg":
    case ".jpeg":
    case ".bmp":
    case ".gif":
      return "https://jszhgd.cn/static/app/image.png";
    default:
      return "https://jszhgd.cn/static/app/other.png";
  }
}
